# 激活函数
import numpy as np
# 1. 阶跃函数的实现
def step_fuction(x:np.array):
    y = x > 0
    y = y.astype(int)
    return y
print(step_fuction(np.array([0,3,3])))

# 2. 阶跃函数的图形
import numpy as np
import matplotlib.pylab as plt

# x = np.arange(-5,5,0.1)
# y = step_fuction(x)
# plt.plot(x,y)
# plt.ylim(-0.1,1.1) # 指定y轴的范围
# plt.show()

# 3. sigmoid函数的实现 -- numpy的广播功能
def sigmoid(x):
    return 1 / (1 + np.exp(-x))

x = np.array([-1.0, 1.0, 2.0])
# print(sigmoid(x))
#
# x = np.arange(-5,5,0.1)
# y = sigmoid(x)
# plt.plot(x,y)
# plt.ylim(-0.1,1.1) # 指定y轴的范围
# plt.show()

# 4. ReLu激活函数
def relu(x):
    return np.maximum(0, x)


